package ru.dimka3210.java.reminder.utils;

import ru.dimka3210.java.reminder.dialogs.InfoByRun;

import javax.swing.*;
import java.io.*;

/**
 * User: dimka3210
 * Date: 17.05.13
 * Time: 22:14
 */
public class IsFirstRun {
    private static IsFirstRun ourInstance = new IsFirstRun();

    public static IsFirstRun getInstance() {
        return ourInstance;
    }

    private IsFirstRun() {
        File _settings = new File("settings.ini");
        final InputStreamReader inputStreamReader;
        try {
            inputStreamReader = new InputStreamReader(new FileInputStream(_settings));
//            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            inputStreamReader.close();
        } catch (FileNotFoundException e) {
            try {
                _settings.createNewFile();
                Global.setFirstRun(true);
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        JDialog infoByRun = new InfoByRun();
                        infoByRun.setVisible(true);
                    }
                });
                System.out.println("_settings->createNewFile");
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
